package main

import (
	"reflect"
	"fmt"
)
/**
	反射练习
 */
func main() {
	user := User{"wangjie", 10}
	userType := reflect.TypeOf(user)
	fmt.Println("reflect type of :", userType)
	userValue := reflect.ValueOf(user)
	fmt.Println("reflect value of :", userValue)
	name, ok := userType.FieldByName("name")
	if ok {
		fmt.Print(reflect.ValueOf(name))
	}
}

type User struct {
	name string
	sex  int
}

func (this *User) GetName() (string) {
	return this.name
}

func (this *User)SetName(name string) {
	this.name = name
}